from django_filters.rest_framework import FilterSet
from django_filters.filters import *
from .models import *


class OperLogFilterSet(FilterSet):
    module = CharFilter(lookup_expr="contains")
    path = CharFilter(lookup_expr="contains")
    method = CharFilter(lookup_expr="contains")
    start_time = DateFilter(
        field_name="create_time", lookup_expr="gte", label="开始日期"
    )
    end_time = DateFilter(field_name="create_time", lookup_expr="lt", label="结束日期")

    class Meta:
        model = OperLog
        fields = ["module", "path", "method", "status", "start_time", "end_time"]
